<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%
String pathHeader = request.getContextPath();
String basePathHeader = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+pathHeader+"/";
%>
<style type="text/css">
.nav1 li a {
	text-align: center;
}
</style>

<div class="page-title col-md-12" style="height: 60px;padding-left: 0;">
	<div class="col-md-4" style="padding-left: 0;">
		<img src="static/images/logo.png" height="60" />
	</div>
	<div class="col-md-8">
		<div class="col-md-12" style="padding-top: 4px;">
			<ul style="list-style: none; margin: 0; float: right; line-height: 26px;">
				<li style="display: inline; cursor: pointer;">尊敬的【<%= request.getAttribute("username") %>】您好,欢迎您的登入！</li>
			</ul>
		</div>
		<div class="col-md-12" >
			<ul style="list-style: none; margin: 0; float: right; line-height: 26px;">
				<li style="display: inline; cursor: pointer;">今天是<%= request.getAttribute("currDate") %>&nbsp;<%= request.getAttribute("currWeekDay") %></li>
				<li style="display: inline; cursor: pointer;" onclick="changePwd()" >【修改密码】</li>
				<li style="display: inline; cursor: pointer;" onclick="signout()">【退出】</li>
			</ul>
		</div>
	</div>
	<div class="clearfix"></div>
</div>

<div class="header" style="background-color: #36AEED">
	<div class="logo-right">
		<span class="menu"><img src="images/menu.png" alt=" " /></span>
		<ul id="menuNav" class="nav1">
			<!-- 
			<li><a href="<%=basePathHeader%>index?menuId=1" class="act"><img
					src="static/images/head/i1.png" /><span>我的物业</span></a></li>
			<li><a href="<%=basePathHeader%>map?menuId=2" class="act"><img
					src="static/images/head/i2.png" /><span>地图展示</span></a></li>
			<li><a href="<%=basePathHeader%>order?menuId=3&liIndex=0"
				class="act"><img src="static/images/head/i3.png" /><span>停车管理</span></a></li>
			<li><a href="<%=basePathHeader%>index?menuId=4" class="act"><img
					src="static/images/head/i4.png" /><span>活动管理</span></a></li>
			<li><a href="<%=basePathHeader%>maintain?menuId=5&liIndex=0"
				class="act"><img src="static/images/head/i5.png" /><span>记录查询</span></a></li>
			<li><a href="<%=basePathHeader%>user?menuId=6&liIndex=0"
				class="act"><img src="static/images/head/i6.png" /><span>报表统计</span></a></li>
			<li><a href="<%=basePathHeader%>system?menuId=7&liIndex=0"
				class="act"><img src="static/images/head/i7.png" /><span>系统管理</span></a></li>
			 -->
			 <%=request.getAttribute("navMenus") %>
		</ul>
	</div>
	<div class="clearfix"></div>
</div>

<!-- MESSAGE BOX-->
<div class="message-box animated fadeIn" data-sound="alert"
	id="mb-signout">
	<div class="mb-container">
		<div class="mb-middle">
			<div class="mb-title">
				<span class="fa fa-sign-out"></span> 注销 ?
			</div>
			<div class="mb-content">
				<p>你确定要注销?</p>
				<p>点击"否"继续工作，点击"是"注销当前用户。</p>
			</div>
			<div class="mb-footer">
				<div class="pull-right">
					<a href="<%=basePathHeader%>signout" class="btn btn-success btn-lg">是</a>
					<button class="btn btn-default btn-lg mb-control-close"
						onclick="cacelSignout()">否</button>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- END MESSAGE BOX-->

<!-- Modal -->
<div class="modal fade" id="passwordModal" tabindex="-1" role="dialog" aria-labelledby="passwordModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="passwordModalLabel">修改密码</h4>
            </div>
            <div class="modal-body">
          		<form id="jvalidate" class="form-horizontal" role="form">                                    
                     <div class="form-group">
                         <label class="col-md-2 control-label">旧密码</label>
                         <div class="col-md-10">
                             <input id="oldPwd" name="oldPwd" type="text" class="form-control" placeholder="请输入旧密码"/>
                         </div>
                     </div>
                     <div class="form-group">
                         <label class="col-md-2 control-label">新密码</label>
                         <div class="col-md-10">
                             <input id="newPwd" name="newPwd" type="text" class="form-control" placeholder="请输入新密码"/>
                         </div>
                     </div>
                 </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="save" onclick="updatePwd()">保存</button>
            </div>
        </div>
    </div>
</div>

<script>
	$(document).ready(function() {
		var navId = '${navId}';
		if(null == navId || '' == navId)
		{
			$("#menuNav").children().eq(0).addClass("cap");
		} else {
			var navId_ = parseInt(navId) - 1 ;
			$("#menuNav").children().removeClass("cap");
			var ul = document.getElementById('menuNav');
			var lis = ul.getElementsByTagName('li');
			for(var i=0;i<lis.length;i++){
				if(i == navId_)
				{
					$("#menuNav").children().eq(navId_).addClass("cap");
					break;
				}
			}
		}
	});

	function signout() {
		$("#mb-signout").addClass("open");
	}

	function cacelSignout() {
		$("#mb-signout").removeClass("open");
	}
	
	function changePwd() {
		$("#oldPwd").val("");
		$("#newPwd").val("");
 		$("#passwordModal").modal("show");
	}
	
	function updatePwd() {
		var oldPwd = $("#oldPwd").val();
    	var newPwd = $("#newPwd").val();
    	var url = ctx + "/system/updatePassword";
    	$.post(
    	 	url,
    	 	{ 
    	 		"oldPwd": oldPwd,
                "newPwd": newPwd
    	 	},
    	 	function(result){
    	 		var rtn = JSON.parse(result);
            	if(rtn.code == 1)
            	{
                	$("#passwordModal").modal("hide");
            	} else {
            		$("#message-box-sound").addClass("open");
					$("#errText").html(rtn.text);
            	}
    	 	}
    	 );
	}
</script>